package a1;

/**
 * Title: Main class for CSIS 235 Assignment #1
 * Description: CS 235 Assignment #1
 *    Basic program that uses the Hand and PlayingCard class.
 * 
 * @author 
 * @email @my.uwrf.edu
 * @date 
 */

public class Main {

	/**
	 * main
	 * @param args
	 */
	public static void main(String[] args) {
		/*
		 * Set up a deck of 52 cards
		 */
		final int DECK_SIZE = 52;
		PlayingCard[] deck = new PlayingCard[DECK_SIZE];
		
		// This is not the way you want to do the assignment - it is just an example
		for (int i=0; i<deck.length; i++){
			int rank = i % 13 + 1;
			int suit = i / 13 + 1;
			deck[i] = new PlayingCard( rank, suit );
		}
		
		/*
		 * Print out all the cards
		 */
		for (int i=0; i<deck.length; i++)
			System.out.println( " " + deck[i] );
		
		Hand pile1 = new Hand();
		// This is not the way you want to do the assignment - it is just an example
		final int PILE1_SIZE = 10;
		for (int i=0; i<PILE1_SIZE; i++){
			int j = (int) ( Math.random() * DECK_SIZE );
			/*
			 * Warning - can result in an infinite loop 
			 * Use with caution!
			 */
			// This is not the way you want to do the assignment - it is just an example
			while (deck[j] == null)
				j = (j + 1) % DECK_SIZE;
				
			// Add the card at location j to pile1
			pile1.addCard( deck[j] );
			// And remove it from the deck
			deck[ j ] = null;
		}
		System.out.println( " Hand 1 has: " + pile1 );
	}
}